package com.ljfiction.book.adapter;

import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ljfiction.book.Baner.FistHom;
import com.ljfiction.book.R;
import com.zhy.autolayout.utils.AutoUtils;

import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/7/8.
 */

public class HothuanyihuanGridViewAdapter extends BaseAdapter{
    private List<FistHom.DataBean.BooklableListBean> datas;
    private List<Integer> intlist=new ArrayList<>();
    public HothuanyihuanGridViewAdapter(List<FistHom.DataBean.BooklableListBean> biaoqianlist, List<Integer> intlist) {
        this.datas=biaoqianlist;
        this.intlist=intlist;
    }
    @Override
    public int getCount() {

        return intlist.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Textbiaoqian textbiaoqian=null;
        if (convertView==null){
            textbiaoqian=new Textbiaoqian();
            convertView= LayoutInflater.from(parent.getContext()).inflate(R.layout.hothuanyihuan_item, null);
            x.view().inject(textbiaoqian,convertView);
            convertView.setTag(textbiaoqian);
            AutoUtils.autoSize(convertView);
        }else {
            textbiaoqian= (Textbiaoqian) convertView.getTag();
        }
        textbiaoqian.textView.setText(datas.get(intlist.get(position)).getBookLableName());

        GradientDrawable gd = (GradientDrawable) textbiaoqian.textView.getBackground();
        gd.setColor(Color.parseColor(datas.get(intlist.get(position)).getBookColor()));
        return convertView;
    }
    public class Textbiaoqian{
        @ViewInject(R.id.biaoqiantext)
        TextView textView;
    }

}
